//
//  EmoticonAttachment.swift
//  KeyboardDemo
//
//  Created by Lucky on 16/5/15.
//  Copyright © 2016年 Lucky. All rights reserved.
//

import UIKit

class EmoticonAttachment: NSTextAttachment {
    
    var chs: String?

    ///根据表情模型创建表情字符串
    class func imageText(emoticon: Emoticon, font: UIFont) -> NSAttributedString {
        //创建属性字符串
        let attachment = EmoticonAttachment()
        attachment.chs = emoticon.chs
        attachment.image = UIImage(contentsOfFile: emoticon.imagePath!)
        attachment.bounds = CGRectMake(0, -4, font.lineHeight, font.lineHeight)
        return NSAttributedString(attachment: attachment)
    }
}
